
#include "includes.h"

uint8_T  bottv_k_cpRatio;
uint16_T bottv_k_cpFreq;
uint8_T  bottv_k_SRSRatio;
uint16_T bottv_k_SRSFreq;

void get_CPSignal(void)
{
	uint16_t freq=0;
	uint8_t  duty=0;
	static uint8_t  cnt1=0;

	Ftm_GetCpPwm(&duty,&freq);

	bottv_k_cpFreq=freq;

	if(bottv_k_cpFreq<1100&&bottv_k_cpFreq>900)
	{
    	cnt1=0;

    	if(duty<=100)
    		bottv_k_cpRatio=100-duty;
		else
			bottv_k_cpRatio=0;
	}
    else
    {
    	if(++cnt1>(500/20))
    	{
    		bottv_k_cpRatio=0;
    		bottv_k_cpFreq=0;
    		cnt1=100;
    	}
    }
}

void get_SRSSignal(void)
{
	uint16_t freq=0;
	uint8_t  duty=0;
	static uint8_t  cnt1=0;

	Ftm_GetSRSPwm(&duty,&freq);

	bottv_k_SRSFreq=freq;

	if(bottv_k_SRSFreq<SRS_FREQ_LIMMAX&&bottv_k_SRSFreq>SRS_FREQ_LIMMIN)
	{
    	cnt1=0;

    	if(duty<=100)
    		bottv_k_SRSRatio=100-duty;
		else
			bottv_k_SRSRatio=0;
	}
    else
    {
    	if(++cnt1>(500/20))
    	{
    		bottv_k_SRSRatio=0;
    		bottv_k_SRSFreq=0;
    		cnt1=100;
    	}
    }
}

void get_PwmSignal(void)
{
	get_CPSignal();
	get_SRSSignal();
}
 
 
